#ifndef _MFloatVector
#define _MFloatVector
//
//-
// ==========================================================================
// Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors.  All 
// rights reserved.
// 
// The coded instructions, statements, computer programs, and/or related 
// material (collectively the "Data") in these files contain unpublished 
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its 
// licensors,  which is protected by U.S. and Canadian federal copyright law 
// and by international treaties.
// 
// The Data may not be disclosed or distributed to third parties or be 
// copied or duplicated, in whole or in part, without the prior written 
// consent of Autodesk.
// 
// The copyright notices in the Software and this entire statement, 
// including the above license grant, this restriction and the following 
// disclaimer, must be included in all copies of the Software, in whole 
// or in part, and all derivative works of the Software, unless such copies 
// or derivative works are solely in the form of machine-executable object 
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. 
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED 
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF 
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, 
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO 
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST 
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR 
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS 
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. 
// ==========================================================================
//+
//
// CLASS:    MFloatVector
//
// *****************************************************************************
//
// CLASS DESCRIPTION (MFloatVector)
//
//	This class provides access to Maya's internal vector math library allowing
//	vectors to be handled easily, and in a manner compatible with internal
//	Maya data structures.
//
// *****************************************************************************

#if defined __cplusplus

// *****************************************************************************

// INCLUDED HEADER FILES



#include <maya/MTypes.h>
#include <maya/MStatus.h>
#include <math.h>

// *****************************************************************************

// DECLARATIONS

class MFloatMatrix;
class MFloatPoint;
class MVector;
class MPoint;
#define MFloatVector_kTol 1.0e-5F

// *****************************************************************************

// CLASS DECLARATION (MFloatVector)

/// A vector math class for vectors of floats. (OpenMaya) (OpenMaya.py)
/**
  This class provides access to Maya's vector math library.
*/
#ifdef _WIN32
#pragma warning(disable: 4522)
#endif // _WIN32

class OPENMAYA_EXPORT MFloatVector  
{
public:
	///
						MFloatVector();
	///
						MFloatVector( const MFloatPoint&);
	///
						MFloatVector( const MFloatVector&);
	///
						MFloatVector( const MVector&);
	///
						MFloatVector( const MPoint&);
	///
						MFloatVector( float xx, float yy, float zz = 0.0);
	///
						MFloatVector( const float[3] );
	///
						~MFloatVector();
	///
 	MFloatVector&		operator= ( const MFloatVector& src );
	///
 	float   			operator()( unsigned int i ) const;
	///
	float				operator[]( unsigned int i )const;
	///
 	MFloatVector		operator^( const MFloatVector& right) const;
	///
 	MFloatVector&   	operator/=( float scalar );
	///
 	MFloatVector 	    operator/( float scalar ) const;
	///
 	MFloatVector& 		operator*=( float scalar );
	///
 	MFloatVector   		operator*( float scalar ) const;
	///
 	MFloatVector   		operator+( const MFloatVector& other) const;
	///
	MFloatVector&		operator+=( const MFloatVector& other );
	///
 	MFloatVector   		operator-() const;
	///
 	MFloatVector   		operator-( const MFloatVector& other ) const;
	///
	MFloatVector&		operator-=( const MFloatVector& other );
	///
 	MFloatVector  		operator*( const MFloatMatrix&) const;
	///
 	MFloatVector&		operator*=( const MFloatMatrix&);
	///
 	float      		    operator*( const MFloatVector& other ) const;
	///
 	bool       		   	operator!=( const MFloatVector& other ) const;
	///
 	bool       	    	operator==( const MFloatVector& other ) const;
	///
	MStatus				get( float[3] ) const;
	///
 	float      		   	length() const;
	///
 	MFloatVector  		normal() const;
	///
	MStatus				normalize();
	///
 	float      		 	angle( const MFloatVector& other ) const;
	///
	bool				isEquivalent( const MFloatVector& other,
									  float tolerance = MFloatVector_kTol )
									  const;
	///
 	bool       		   	isParallel( const MFloatVector& other,
									float tolerance = MFloatVector_kTol )
									const;
BEGIN_NO_SCRIPT_SUPPORT:

	///	NO SCRIPT SUPPORT
 	float&     		 	operator()( unsigned int i );

	///	NO SCRIPT SUPPORT
 	float&     		 	operator[]( unsigned int i );

	///	NO SCRIPT SUPPORT
	MFloatVector		transformAsNormal( const MFloatMatrix & matrix ) const;

	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( int,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( short,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( unsigned int,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( unsigned short,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( float,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( double,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
 	friend OPENMAYA_EXPORT MFloatVector	operator*( const MFloatMatrix&,
												   const MFloatVector& );
	///	NO SCRIPT SUPPORT
	friend OPENMAYA_EXPORT std::ostream& operator<<( std::ostream& os,
												const MFloatVector& v );

END_NO_SCRIPT_SUPPORT:

	/// The null vector
	static const MFloatVector zero;
	/// The vector <1.0,1.0,1.0>
	static const MFloatVector one;
	/// Unit vector in the positive x direction
	static const MFloatVector xAxis;
	/// Unit vector in the positive y direction
	static const MFloatVector yAxis;
	/// Unit vector in the positive z direction
	static const MFloatVector zAxis;
	/// Unit vector in the negative z direction
	static const MFloatVector xNegAxis;
	/// Unit vector in the negative z direction
	static const MFloatVector yNegAxis;
	/// Unit vector in the negative z direction
	static const MFloatVector zNegAxis;
	/// The x component of the vector
	float x;
	/// The y component of the vector
	float y;
	/// The z component of the vector
	float z;

protected:
// No protected members

private:
// No private members

};

#ifdef WANT_GCC41_FRIEND
MFloatVector	operator*( int, const MFloatVector& );
MFloatVector	operator*( short, const MFloatVector& );
MFloatVector	operator*( unsigned int, const MFloatVector& );
MFloatVector	operator*( unsigned short, const MFloatVector& );
MFloatVector	operator*( float, const MFloatVector& );
MFloatVector	operator*( double, const MFloatVector& );
#endif


#ifdef _WIN32
#pragma warning(default: 4522)
#endif // _WIN32

inline MFloatVector::MFloatVector()
 	: x(0.0)
	, y(0.0)
	, z(0.0)
{
}

inline MFloatVector::MFloatVector(const MFloatVector& src)
 	: x(src.x)
	, y(src.y)
	, z(src.z)
{
}

inline MFloatVector::MFloatVector(float xx, float yy, float zz)
 	: x(xx)
	, y(yy)
	, z(zz)
{
}

inline MFloatVector::MFloatVector( const float d[3] )
 	: x(d[0])
	, y(d[1])
	, z(d[2])
{
}

inline MFloatVector::~MFloatVector()
{
}

inline MFloatVector& MFloatVector::operator= (const MFloatVector& src)
{
	x=src.x;
	y=src.y;
	z=src.z;
	return (*this);
}

inline float& MFloatVector::operator()( unsigned int i )
{
	if( i== 0 )			return x;
	else if( i== 1 )	return y;
	else				return z;
}

inline float MFloatVector::operator()( unsigned int i ) const
{
	if( i== 0 )			return x;
	else if( i== 1 )	return y;
	else				return z;
}

inline float& MFloatVector::operator[]( unsigned int i )
{
	if( i== 0 )			return x;
	else if( i== 1 )	return y;
	else				return z;
}

inline float MFloatVector::operator[]( unsigned int i ) const
{
	if( i== 0 )			return x;
	else if( i== 1 )	return y;
	else				return z;
}

inline MFloatVector MFloatVector::operator^ (const MFloatVector& right) const
{
	return MFloatVector(y*right.z - z*right.y,
						z*right.x - x*right.z,
						x*right.y - y*right.x);
}

inline MFloatVector& MFloatVector::operator*= (float scalar)
{
	x *= scalar;
	y *= scalar;
	z *= scalar;
	return *this;
}

inline MFloatVector MFloatVector::operator* ( float scalar ) const
{
	MFloatVector tmp(*this);
	tmp *= scalar;
	return tmp;
}

inline MFloatVector& MFloatVector::operator/= (float scalar)
{
	x /= scalar;
	y /= scalar;
	z /= scalar;
	return *this;
}

inline MFloatVector MFloatVector::operator/ ( float scalar ) const
{
	MFloatVector tmp(*this);
	tmp /= scalar;
	return tmp;
}

inline MFloatVector MFloatVector::operator- (const MFloatVector& other) const
{
	return MFloatVector(x-other.x, y-other.y, z-other.z);
}

inline MFloatVector MFloatVector::operator+ (const MFloatVector& other) const
{
	return MFloatVector(x+other.x, y+other.y, z+other.z);
}

inline MFloatVector& MFloatVector::operator+= (const MFloatVector& other)
{
	x += other.x;
	y += other.y;
	z += other.z;
	return *this;
}

inline MFloatVector& MFloatVector::operator-= (const MFloatVector& other)
{
	x -= other.x;
	y -= other.y;
	z -= other.z;
	return *this;
}

inline MFloatVector MFloatVector::operator- () const
{
	return MFloatVector(-x,-y,-z);
}

inline float MFloatVector::operator* (const MFloatVector& right) const
{
	return (x*right.x + y*right.y + z*right.z);
}

inline MStatus MFloatVector::get( float d[3] ) const
{
	if(d != NULL)
	{
		d[0] = x;
		d[1] = y;
		d[2] = z;
		return MS::kSuccess ;
	}
	return MS::kFailure;
}

inline MStatus MFloatVector::normalize()
{
	float lensq = x*x + y*y + z*z;
	if(lensq>1e-20) {
		float factor = 1.0f / sqrtf(lensq);
		x *= factor;
		y *= factor;
		z *= factor;
	}
	return MS::kSuccess;
}

inline MFloatVector MFloatVector::normal() const
{
	MFloatVector tmp(*this);
	tmp.normalize();
	return tmp;
}

inline float MFloatVector::length() const
{
	return sqrtf(x*x+y*y+z*z);
}

inline bool MFloatVector::operator== (const MFloatVector& other) const
{
	return (x == other.x && y == other.y && z == other.z);
}

inline bool MFloatVector::operator!= (const MFloatVector& other) const
{ 
	return !(*this == other); 
}

inline MFloatVector operator * (int scalar, const MFloatVector& other)
{
	return float(scalar) * other;
}

inline MFloatVector operator * (short scalar, const MFloatVector& other)
{
	return float(scalar) * other;
}

inline MFloatVector operator * (unsigned int scalar, const MFloatVector& other)
{
	return float(scalar) * other;
}

inline MFloatVector operator * (unsigned short scalar, const MFloatVector& other)
{
	return float(scalar) * other;
}

inline MFloatVector operator * (float scalar, const MFloatVector& other)
{
	return MFloatVector(scalar*other.x, scalar*other.y, scalar*other.z);
}

inline MFloatVector operator * (double scalar, const MFloatVector& other)
{
	return float(scalar) * other;
}
// *****************************************************************************
#endif /* __cplusplus */
#endif /* _MFloatVector */
